package sandbox.keki.aut.bme.hu;

import sajat.onlab.AppEngAsyncTask;
import sajat.onlab.R;
import android.app.Activity;
import android.os.Bundle;
import android.text.TextWatcher;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;

public class ServerActivity extends Activity {
	private EditText etLatitude;
	private EditText etLongitude;
	private Spinner spinner;
	private Button btnSend;
	private Button btnReq;
	private TextView tvResp;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.serverlayout);

		etLatitude = (EditText) findViewById(R.id.etLatitude);
		etLongitude = (EditText) findViewById(R.id.etLongitude);
		spinner = (Spinner) findViewById(R.id.spinner);
		tvResp = (TextView) findViewById(R.id.tvResp);
		btnSend = (Button) findViewById(R.id.btnSend);
		btnSend.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				AppEngAsyncTask appEngTask = new AppEngAsyncTask(tvResp, AppEngAsyncTask.Mode.SEND);
				appEngTask.execute(Integer.parseInt(etLatitude.getText().toString()), Integer.parseInt(etLongitude.getText().toString()));
			}
		});
		btnReq = (Button) findViewById(R.id.btnReq);
		btnReq.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				AppEngAsyncTask appEngTask = new AppEngAsyncTask(tvResp, AppEngAsyncTask.Mode.REQUEST);
				appEngTask.execute();
			}
		});
		
		String[] users = new String[] {"kp","kg","ep","fj"};
		spinner.setAdapter(new ArrayAdapter(this, android.R.layout.simple_spinner_item, users));
	}
}
